import {reqLogin} from '@/api/user'
export default {
  namespaced: true,
  state: {
    token: '', // 用户登录后唯一标识
    name: '' // 用户名
  },
  actions: {
    async login({ commit }, { phone, password }) {
      const result = await reqLogin(phone, password);
      commit("LOGIN", result);
    },
  },
  mutations: {
    LOGIN(state, user) {
      // 存储到vuex中
      state.name = user.name;
      state.token = user.token;

    },
  }
}
